import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kepu/model/game_entity.dart';
import 'package:kepu/util/http_util.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'game_provider.g.dart';

@Riverpod(keepAlive: true)
Future<GameEntity> game(Ref ref) async {
  var isAnimalGame = ref.watch(isAnimalGameTypeProvider);
  var response =
      isAnimalGame
          ? await DioInstance.instance().get(path: "game/animal")
          : await DioInstance.instance().get(path: "game/plant");
  return GameEntity.fromJson(response.data);
}


@riverpod
class IsAnimalGameType extends _$IsAnimalGameType {
  @override
  bool build() {
    return true;
  }

  void toggle() {
    state = !state;
  }
}
